package com.tm.chargecar.service.impl;

import com.tm.chargecar.dto.DogcarRepairDto;
import com.tm.chargecar.entity.DogcartRepairEntity;
import com.tm.chargecar.mapper.DogcartRepairMapper;
import com.tm.chargecar.result.Result;
import com.tm.chargecar.service.DogcartRepairService;
import com.tm.chargecar.utils.PageUtil;
import com.tm.chargecar.vo.DogcartRepairVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author wangSang
 * @create 2022-08-24 9:52
 *
 * 设备管理保修记录  service
 */
@Service
public class DogcartRepairServiceImpl implements DogcartRepairService {

    @Autowired
    private DogcartRepairMapper dogcartRepairMapper;

    /**
     *  设备管理保修 分页加条件查询
     * @param dogcartRepairVo
     * @return
     */
    @Override
    public   PageUtil   queryDogcartRepair(DogcartRepairVo dogcartRepairVo) {
        // 创建分页工具
        PageUtil pageUtil = new PageUtil();
        // 查询总条数
        Long  totalCouunt   =    dogcartRepairMapper.quertyCount(dogcartRepairVo);
        // 将总条数放入 工具类
        pageUtil.setTotalCount(totalCouunt);
        //  查出分页数据
       List<DogcarRepairDto> dogcartRepairEntityList = dogcartRepairMapper.queryDogcartRepair(dogcartRepairVo);
        pageUtil.setData(dogcartRepairEntityList);
        return pageUtil;
    }

    @Override
    public Result updateDogcartRepair(DogcartRepairEntity dogcartRepairEntity) {


        dogcartRepairMapper.updateDogcartRepair(dogcartRepairEntity);


        return Result.SUCCESS("修改成功");
    }

    @Override
    public Result deleteDogcartRepair(Integer id) {

        dogcartRepairMapper.deleteDogcartRepair(id);

        return Result.SUCCESS("删除成功");
    }

    @Override
    public Result addDogcartRepair(DogcartRepairEntity dogcartRepairEntity) {

        dogcartRepairMapper.addDogcartRepair(dogcartRepairEntity);
        return Result.SUCCESS("新增成功");
    }
}
